//
//  ElevatorCheckViewController.m
//  Qihuo
//
//  Created by Vencoo on 14-1-8.
//  Copyright (c) 2014年 Vencoo. All rights reserved.
//

#import "ElevatorCheckViewController.h"
#import "ParentCheckCell.h"
@interface ElevatorCheckViewController ()
{
    int row ;
}
@end

@implementation ElevatorCheckViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    self.checkURL = resultOfElevater;
    self.checkNames = @[@"3F ",@"4F ",@"5F ",@"6F ",@"7F ",@"8F ",@"9F ",@"10F  ",@"11F ",@"12F ",@"备注"];
    [super viewDidLoad];
    self.title = @"垂直电梯自检记录";
    row = 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *identifier = [NSString stringWithFormat:@"cell%d",indexPath.row];
    ParentCheckCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell)
    {
        cell = [[ParentCheckCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        if (self.floorCheckDatas.count > 0)
        {
            NSArray *checkDatas = [self.floorCheckDatas objectAtIndex:indexPath.row];
            for (int i = 0; i < checkDatas.count; i ++)
            {
                NSDictionary *checkDic = [checkDatas objectAtIndex:i];
                NSString *checkResult = @"";
                if ([checkDic objectForKey:@"result"])
                {
                    checkResult = [NSString stringWithFormat:@"%@",[checkDic objectForKey:@"result"]];
                }
                else if ([checkDic objectForKey:@"isNormal"])
                {
                    checkResult = [NSString stringWithFormat:@"%@",[checkDic objectForKey:@"isNormal"]];
                }
                CGSize mySz;
                //                if ([checkResult isEqualToString:@"0"])
                //                {
                //                    UIImage *rightImage = [UIImage imageNamed:@"正常"];
                //                    mySz = rightImage.size;
                //                    UIImageView *rightView = [[UIImageView alloc]initWithImage:rightImage];
                //                    control = (UIControl*)rightView;
                //                }
                
                UILabel *resultLb = [UILabel new];
                resultLb.text = checkResult;
                resultLb.font = [UIFont systemFontOfSize:20];
                mySz = [[NSString stringWithFormat:@"巴巴爸爸"] sizeWithFont:resultLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
                
                if (resultLb.text.length <= 4)
                {
                    resultLb.frame = CGRectMake(cell.floorNameLb.frame.origin.x + cell.floorNameLb.frame.size.width - 50 + i * 82,cell.floorNameLb.frame.origin.y, mySz.width, mySz.height);
                }
                resultLb.numberOfLines = 0;
                resultLb.textAlignment = 1;
                [cell addSubview:resultLb];
            }
        }
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if (self.floorNames.count > 0) {
        cell.floorNameLb.text = [self.floorNames objectAtIndex:indexPath.row];
    }
    if (self.floorRemarks.count > 0) {
        cell.remarkLb.text = [self.floorRemarks objectAtIndex:indexPath.row];
    }
    return cell;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
